package com.tianzeculture.stagebao.net;

import com.tianzeculture.stagebao.bean.JobListBean;
import com.tianzeculture.stagebao.bean.Notice;
import com.tianzeculture.stagebao.bean.NoticeList;
import com.tianzeculture.stagebao.bean.ResultBean;
import com.tianzeculture.stagebao.bean.ResumeListResult;
import com.tianzeculture.stagebao.bean.User;
import com.tianzeculture.stagebao.net.base.AppBaseRestUsageV2;
import com.tianzeculture.stagebao.network.net.httpclient.NewCustomResponseHandler;
import com.tianzeculture.stagebao.util.Util;

import java.util.HashMap;
import java.util.Map;

import static android.R.attr.tag;

/**
 * Created by Administrator on 2018/7/18 0018.
 */

public class BusinessRestUsage extends AppBaseRestUsageV2 {

    private String TO_WORKER = "/search/job.do";//招募
    private String TO_WORKER_DETAILS = "/work/toWorkerDetails.do";//招募详情页(作废)
    private String TO_SELLER_DETAILS = "/work/toSellerdetails.do";//商家详情页
    private String SAVE_ANNOUNCEMENT = "/work/saveAnnouncement.do";//发布通告
    private String UPDATE_ANNOUNCEMENT = "/work/updateAnnouncement.do";//编辑招募信息
    private String APPLY_WORK = "/work/joinWorker.do";//申请工作
    private String TO_ORDER = "/order/toOrder.do";//通告列表
    private String APPLYJOP = "/applyJop/resumeList.do";//简历列表
    private String DELEJOB = "/search/deljob.do";//删除招募信息
    private String UPDAPTE_JOP = "/applyJop/upState.do";//更改简历已读状态
    private String ORDER_STATUS = "/order/updateType.do";//更改沟通状态


    /**
     * 通告列表
     */
    public void toOrder(int taskId, String type, int page, int pageSize) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("type", type);
        paramMap.put("page", String.valueOf(page));
        paramMap.put("pageSize", String.valueOf(pageSize));
        post(TO_ORDER, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 简历列表
     */
    public void getResumeList(int taskId, String type, String userId, int page, int pageSize) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("type", type);
        paramMap.put("userId", userId);
        paramMap.put("page", String.valueOf(page));
        paramMap.put("size", String.valueOf(pageSize));
        post(APPLYJOP, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResumeListResult>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 已沟通通告列表
     */
    public void toAlreadyOrder(int taskId, String type, int page, int pageSize, String ischat) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("type", type);
        paramMap.put("ischat", ischat);
        paramMap.put("page", String.valueOf(page));
        paramMap.put("pageSize", String.valueOf(pageSize));
        post(TO_ORDER, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 沟通状态
     */
    public void updateOrderStatus(int taskId, String orderId, String ischat) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("orderId", orderId);
        paramMap.put("ischat", ischat);
        post(ORDER_STATUS, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

//    /**
//     * 招募(默认所有招募信息)
//     */
//    public void toWorker(int taskId, String search, int page, int pageSize) {
//        Map<String, String> paramMap = new HashMap<>();
//        paramMap.put("search", search);
//        paramMap.put("page", String.valueOf(page));
//        paramMap.put("pageSize", String.valueOf(pageSize));
//        post(TO_WORKER, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
//        }.setCallSuperRefreshUI(true));
//    }

    /**
     * 招募
     */
    public void toWorker(int taskId, Notice notice, int page, int pageSize) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("content", notice.getContent());
        paramMap.put("address", notice.getAddress());
        paramMap.put("istravel", notice.getIstravel());
        paramMap.put("iscostume", notice.getIscostume());
        paramMap.put("sex", notice.getSex());
        paramMap.put("addTime", notice.getAddTime());
        paramMap.put("workType", notice.getWorkType());
        paramMap.put("starttime", notice.getStratTime());
        paramMap.put("endtime", notice.getEndTime());
        paramMap.put("page", String.valueOf(page));
        paramMap.put("pageSize", String.valueOf(pageSize));
        post(TO_WORKER, Util.returnRealParam(paramMap), new NewCustomResponseHandler<JobListBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 招募详情页
     */

    public void toWorkerDetails(int taskId, int workId) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("workId", String.valueOf(workId));
        post(TO_WORKER_DETAILS, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 商家详情页面
     */
    public void toSellerdetails(int taskId, String userId) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("userId", userId);
        post(TO_SELLER_DETAILS, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 申请工作
     */
    public void joinWorker(int taskId, String workId, String userId, String beUserId) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("workId", workId);
        paramMap.put("userId", userId);
        paramMap.put("beUserId", beUserId);
        post(APPLY_WORK, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 删除招募信息
     */
    public void deleteNotice(int taskId, String workId) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("id", workId);
        post(DELEJOB, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 发布通告
     * jobContent : 工作内容 announcement:通告图地址  workNote:工作标签
     * istravel :是否提供路费 （0-否  1-是）  iscostume 演出服（0-否  1-是）
     * indust：工作类型  workName:工作主题 stratTime:开始时间   endTime:结束时间 workarea:工作地点
     * worknumber：人数  workmoney:人均预算  workSex:性别要求    workheight:身高要求
     */
    public void saveAnnouncement(int taskId, Notice notice) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("jobContent", notice.getJobContent());
        paramMap.put("announcement", notice.getAnnouncement());
        paramMap.put("workNote", notice.getWorkNote());
        paramMap.put("tag", notice.getWorkNote());
        paramMap.put("istravel", String.valueOf(notice.getIstravel()));
        paramMap.put("iscostume", String.valueOf(notice.getIscostume()));
//        paramMap.put("work_type", notice.getWork_type());
        paramMap.put("indust", notice.getIndust());
        paramMap.put("workName", notice.getWorkName());
        paramMap.put("stratTime", notice.getStratTime());
        paramMap.put("endTime", notice.getEndTime());
        paramMap.put("workarea", notice.getWorkarea());
        paramMap.put("worknumber", String.valueOf(notice.getWorknumber()));
        paramMap.put("workmoney", String.valueOf(notice.getWorkmoney()));
        paramMap.put("priceType", notice.getPriceType());
        paramMap.put("workSex", String.valueOf(notice.getWorkSex()));
        paramMap.put("workheight", notice.getWorkheight());
        post(SAVE_ANNOUNCEMENT, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }


    /**
     * 编辑修改招募信息
     */
    public void updateAnnouncement(int taskId, NoticeList notice) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("id", notice.getId());
        paramMap.put("work_type", notice.getWorkType());
        paramMap.put("jobContent", notice.getContent());
        paramMap.put("address", notice.getAddress());
        paramMap.put("workNote", notice.getTag());
        paramMap.put("istravel", String.valueOf(notice.getIstravel()));
        paramMap.put("iscostume", String.valueOf(notice.getIscostume()));
        paramMap.put("addPeople", notice.getAddPeople());
        paramMap.put("people", notice.getPeople() + "");
        paramMap.put("addTime", notice.getAddTime());
        paramMap.put("starttime", notice.getStarttime());
        paramMap.put("endtime", notice.getEndtime());
        paramMap.put("tag", notice.getTag());
        paramMap.put("title", notice.getTitle());
        paramMap.put("price_type", notice.getPriceType());
        paramMap.put("sex", notice.getSex());
        paramMap.put("height", notice.getHeight());
        paramMap.put("unitPrice", notice.getUnitPrice() + "");
        paramMap.put("content", notice.getContent());
//        paramMap.put("type", "1");
        post(UPDATE_ANNOUNCEMENT, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

    /**
     * 更改简历已读状态
     */
    public void updateResume(int taskId, String ajId) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("ajId", ajId);
        post(UPDAPTE_JOP, Util.returnRealParam(paramMap), new NewCustomResponseHandler<ResultBean>(taskId) {
        }.setCallSuperRefreshUI(true));
    }

}
